Skip to content

Conversation

@tuhalf
Copy link
Collaborator

@tuhalf tuhalf commented Dec 17, 2025

Fixes issue: #197
Validate every inbound message is valid single-value RLP before processing; if framing is broken, log and close the connection since recovery is impossible. Add regression tests covering invalid RLP closure and the customer-reported broken frame, while ensuring valid-but-unsupported requests don’t close the client.

Validate every inbound message is valid single-value RLP before processing; if framing is broken, log and close the connection since recovery is impossible. Add regression tests covering invalid RLP closure and the customer-reported broken frame, while ensuring valid-but-unsupported requests don’t close the client.
@tuhalf tuhalf linked an issue Dec 17, 2025 that may be closed by this pull request
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tuhalf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical stability issue where malformed RPC frames could lead to client 'doom loops.' It introduces robust RLP validation for all incoming messages. If an inbound message exhibits unrecoverable broken RLP framing, the connection is now gracefully closed to prevent continuous processing of invalid data. Crucially, this change ensures that valid RPC requests, even if unsupported by the client, do not trigger connection closures, maintaining client resilience. Comprehensive test cases have been added to validate these new behaviors.

Highlights

  • Robust RPC Frame Validation: Introduced comprehensive RLP (Recursive Length Prefix) validation for all inbound RPC messages to ensure data integrity and prevent processing of malformed frames.
  • Preventing Doom Loops: Implemented a mechanism to immediately close connections upon detecting unrecoverable broken RLP framing, effectively preventing client 'doom loops' caused by continuous processing of invalid data.
  • Enhanced Test Coverage: Added new regression tests to cover scenarios involving invalid RLP closure, a specific customer-reported broken frame, and confirmed that valid but unsupported requests do not lead to connection termination.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a robust mechanism to handle broken RPC frames by validating inbound RLP messages. If a message is not a valid, single-value RLP, the connection is now correctly closed to prevent processing loops. This is a critical fix for connection stability. The change is well-supported by a new suite of regression tests that cover invalid RLP, valid but unsupported requests, and the specific broken frame that triggered the original issue. My review includes a couple of suggestions to improve the new test code for better maintainability and robustness.

Comment on lines +15 to +18
cfg := testConfig()
config.AppConfig = cfg
pool := NewPool()
client := NewClient("localhost:0", nil, cfg, pool)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This client setup logic is repeated across TestHandleInboundMessage_ClosesOnInvalidRLP, TestHandleInboundMessage_DoesNotCloseOnValidUnsupportedRequest, and TestHandleInboundMessage_ClosesOnBrokenFrameFromLog. To improve maintainability and reduce code duplication, consider extracting this into a test helper function.

For example:

func newTestClient(t *testing.T) *Client {
	t.Helper()
	cfg := testConfig()
	config.AppConfig = cfg
	pool := NewPool()
	return NewClient("localhost:0", nil, cfg, pool)
}

Each test could then be simplified to start with client := newTestClient(t).

t.Fatalf("expected invalid RLP for reported frame")
}

msg := edge.Message{Len: 398, Buffer: buf}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The message length is hardcoded as 398. It's more robust to use len(buf) to dynamically set the length. This ensures the test remains correct even if the test data in buf is modified in the future.

Suggested change
msg := edge.Message{Len: 398, Buffer: buf}
msg := edge.Message{Len: len(buf), Buffer: buf}

@tuhalf tuhalf mentioned this pull request Dec 17, 2025
@dominicletz
Copy link
Member

We have no validation yet that this is solving the issue in the field, but the artificial unit tests show that at least the RLP test works.

@dominicletz dominicletz merged commit ae7b2c8 into master Dec 19, 2025
16 checks passed
@dominicletz dominicletz deleted the tuhalf/rpc-request-doom-loop branch December 19, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RPC request doom loop

3 participants